package org.feidao.chapter65.config;

import org.springframework.amqp.core.*;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
/**
 * Created by linghufeixia on 2022-12-28.
 * topic config
 */
@Configuration
public class TopicConfig {
    String routeKeyA = "project1.station1.*";
    String routeKeyB = "project1.*.*";

    @Bean("topic_exchange")
    public TopicExchange topicExchange() {
        return ExchangeBuilder.topicExchange("topic_exchange").durable(true).build();
    }

    @Bean("topic_queue_A")
    public Queue topicQueueA(){
        return QueueBuilder.durable("topic_queue_A").build();
    }

    @Bean
    public Binding topicBindA(){
        return BindingBuilder.bind(topicQueueA()).to(topicExchange()).with(routeKeyA);
    }

    @Bean("topic_queue_B")
    public Queue topicQueueB(){
        return QueueBuilder.durable("topic_queue_B").build();
    }

    @Bean
    public Binding topicBindB(){
        return BindingBuilder.bind(topicQueueB()).to(topicExchange()).with(routeKeyB);
    }
}
